new Vue({
    el: '#app',
    data() {
      return {
        form: {
          Data: "payment_info",
          page: 1,			//页数
          limit: 10			//每页数据条数
        },
        tableData: [],		//表格数据
        total: 1,
      }
    },
    mounted() {
      this.getList(this.form)
    },
    methods: {
      onSerach() {				//查询方法
        console.log("搜搜")
      },
      addContract() {
        window.location.href = './Add.html'
      },
      handleSizeChange(val) {
        this.form.page = 1;
        this.form.limit = val;
        this.getList(this.form)
      },
      handleCurrentChange(val) {
        this.form.page = val;
        this.getList(this.form)
      },
      getList(data) {     //换页方法
        const _this = this
        $.ajax({
          type: 'POST',
          url: DomainName + '/getTableInquiryAction?token='+$.cookie("token"),
          data,
          complete: function (XMLHttpRequest) {
            if (XMLHttpRequest.getResponseHeader("REDIRECT") == "REDIRECT") {
              window.parent.document.location.href = "../../../" + XMLHttpRequest.getResponseHeader("CONTENTPATH");
            }
          },
          success: function (Result) {
            if (Result.Status=='success') {
              _this.tableData = Result.tableData 
              _this.total = parseInt(Result.limit)
            }
          },
          dataType: "json"
        });
      },
      editMember(Merchant_SerialNumber) {
        console.log(Merchant_SerialNumber);
        sessionStorage.setItem("Merchant_SerialNumber", Merchant_SerialNumber)
        window.location.href = './Edit.html?Merchant_SerialNumber=' + Merchant_SerialNumber
      },
      handleSelectionChange(val) {
        this.multipleSelection = val;
      },
      deletMember(row) {
        const _this = this;
        this.$confirm('此操作将删除该商户类型, 是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning',
        }).then(() => {
          row.Row_Status = '1'
          let data = { Data: JSON.stringify({ Modify: { merchant_info: [row] } }) };
          $.ajax({
            url: DomainName + '/getEditAction?token=' + $.cookie('token'),
            type: 'POST',
            data,
            error: function () {
              _this.$message.error("删除失败，请稍后再试")
            },
            complete: function (XMLHttpRequest) {
              _this.loading = false
              if (XMLHttpRequest.getResponseHeader("REDIRECT") == "REDIRECT") {
                window.parent.document.location.href = "../../../" + XMLHttpRequest.getResponseHeader("CONTENTPATH");
              }
            },
            success:function (res) {
              if (res.Status == 'success') {
                _this.$message({
                  type: 'success',
                  message: '删除成功!'
                });
                _this.getList(_this.form)
              }
            }
          })
        }).catch(() => {
          this.$message({
            type: 'warning',
            message: '已取消删除'
          });
        });
      },
    },
  })